package view;

import java.util.ArrayList;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

public class CustomerTableModel implements TableModel{
	//http://www.dreamincode.net/forums/topic/62384-display-arraylist-string-object-in-jtable/
	private ArrayList<String> arrayListData;
	private String[] columnNames;

	public CustomerTableModel(ArrayList<String> arrayListData, String columnNames) 
	{
		this.columnNames = new String[] {columnNames};
		this.arrayListData = arrayListData;
	}

	@Override
	public void addTableModelListener(TableModelListener l)
	{
	}


	@Override
	public Class<?> getColumnClass(int columnIndex)
	{
		return String.class;
	}

	@Override
	public int getColumnCount()
	{
		return 1;
	}

	@Override
	public String getColumnName(int columnIndex)
	{
		return columnNames[columnIndex];
	}

	@Override
	public int getRowCount()
	{
		return arrayListData.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex)
	{
		return arrayListData.get(rowIndex);
	}

	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex)
	{
		return false;
	}
	@Override
	public void removeTableModelListener(TableModelListener l)
	{
	}
	
	@Override
	public void setValueAt(Object value, int rowIndex, int columnIndex)
	{
	}
}